Page({
  data: {
    titleLink: 'https://www.bilibili.com/video/BV1uS4y1b7R7/?spm_id_from=333.337.search-card.all.click&vd_source=86e6599136baf54bf05a747806c782e2',
    descLink: 'https://www.bilibili.com/video/BV1uS4y1b7R7/?spm_id_from=333.337.search-card.all.click&vd_source=86e6599136baf54bf05a747806c782e2'
  },
  onLoad() {},
  onShow() {
    const tabBar = this.getTabBar && this.getTabBar();
    if (tabBar && typeof tabBar.setSelected === 'function') {
      tabBar.setSelected(1);
    }
  },
  onTapLink(e) {
    const url = e.currentTarget.dataset.url;
    if (!url) return;
    // external http(s): open via webview page
    if (/^https?:\/\//.test(url)) {
      const encoded = encodeURIComponent(url);
      wx.navigateTo({ url: `/pages/webview/index?url=${encoded}` });
      return;
    }
    const isTab = url === '/pages/challenge/index' || url === '/pages/video/index' || url === '/pages/profile/index';
    if (isTab) {
      wx.switchTab({ url });
    } else {
      wx.navigateTo({ url });
    }
  }
});


